<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
  <head>
    <base href="<%=basePath%>">
    <%@ taglib uri="/struts-tags" prefix="s"%>
    <%@include file="./headMeta.jsp" %>
  </head>
  <body class="skin-blue">
    <%@include file="./header.jsp" %>
    <div class="wrapper row-offcanvas row-offcanvas-left">
        <!-- Left side column. contains the logo and sidebar -->
        <%@include file="./sidebar.jsp" %>

      <!-- Right side column. Contains the navbar and content of the page -->
      <aside class="right-side">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                员工
            </h1>
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-md-6">
                    <div class="box box-primary">
                        <div class="box-header">
                            <h3 class="box-title">员工列表</h3>
                            <div class="box-tool" style="margin: 7px 7px 0 0;">
                                <ul class="pagination pagination-sm no-margin pull-right">
                                    <li><a href="javascript:void(0)">&laquo;</a></li>
                                    <li><a href="javascript:void(0)">1</a></li>
                                    <li><a href="javascript:void(0)">2</a></li>
                                    <li><a href="javascript:void(0)">3</a></li>
                                    <li><a href="javascript:void(0)">&raquo;</a></li>
                                </ul>
                            </div>
                        </div><!-- /.box-header -->
                        <div class="box-body no-padding">
                            <table class="table table-striped">
                                <tr>
                                    <th style="width: 15%">员工编号</th>
                                    <th>账号</th>
                                    <th>密码</th>
                                    <th style="width: 15%">权限</th>
                                    <th style="width: 10%"></th>
                                    <th style="width: 10%"></th>
                                </tr>
                                <s:iterator value="#listuser" status="st">
                                  <tr>
                                    <td>${id}</td>
                                    <td>${username }</td>
                                    <td>${pwd}</td>
                                    <td>${power }</td>
                                    <td><a href="user/manageUser.action?id=${id}" class="btn btn-primary btn-xs">编辑</a></td>
                                    <td><a href="user/delUser.action?id=${id }" class="btn btn-primary btn-xs">删除</a></td>
                                  </tr>
                                </s:iterator>
                            </table>
                        </div><!-- /.box-body -->
                    </div><!-- /.box -->
                </div><!-- /.col -->
                <div class="col-md-6">
                    <!-- general form elements -->
                    <div class="box box-primary">
                        <div class="box-header">
                            <h3 class="box-title">添加员工</h3>
                        </div><!-- /.box-header -->
                        <!-- form start -->
                        <form role="form" action="user/addUser.action" method="post" id="ufrm">
                            <div class="box-body">
                                <div class="form-group">
                                    <label for="inputUsername">姓名</label>
                                    <input type="text" name="username" class="form-control validate[require, maxlength=6]" id="inputUsername" placeholder="请输入员工姓名" data-title="员工姓名" />
                                </div>
                                <div class="form-group">
                                    <label for="inputPwd">密码</label>
                                    <input type="text" name="pwd" class="form-control validate[require, expression=/[a-z0-9A-Z]/, maxlength=8,minlength=4]" id="inputPwd" placeholder="请输入员工密码" data-title="员工密码" />
                                </div>
                                <div class="form-group">
                                    <label>权限</label>
                                    <select class="form-control" name="power">
                                        <option value="1">收银人员</option>
                                        <option value="2">值班经理</option>
                                    </select>
                                </div>
                            </div><!-- /.box-body -->

                            <div class="box-footer">
                                <button type="submit" class="btn btn-primary">提交</button>
                            </div>
                        </form>
                    </div><!-- /.box -->
                </div>
            </div><!-- /.row -->
        </section><!-- /.content -->   
      </aside>
    </div><!-- ./wrapper -->
  </body>
  <%@include file="./javascript.jsp" %>
       <!-- 校验 -->
<script src="resource/js/validate.js" type="text/javascript"></script>
<script>
		validate.initValidate("ufrm");
		
		$("#ufrm").submit(function(){
			if(validate.validate("ufrm") == false){
				alert(validate.error);
				return false;
			}
		});
		
	</script>
</html>